#include "stdafx.h"

#include <algorithm>
#include <vector>
#include <iostream>

#include <gtest/gtest.h>

TEST(TestAlgorithm, equal)
{
	using namespace std;
   vector <int> v1, v2, v3;
   vector <int>::iterator Iter1, Iter2, Iter3;

   int i;
   for ( i = 0 ; i <= 5 ; i++ )
   {
      v1.push_back( 5 * i );
   }

   int ii;
   for ( ii = 0 ; ii <= 6 ; ii++ )
   {
      v2.push_back( 5 * ii );
   }

   int iii;
   for ( iii = 0 ; iii <= 5 ; iii++ )
   {
      v3.push_back( 10 * iii );
   }
   
   cout << "v1 = ( " ;
   for ( Iter1 = v1.begin( ) ; Iter1 != v1.end( ) ; Iter1++ )
      cout << *Iter1 << " ";
   cout << ")" << endl;

   cout << "v2 = ( " ;
   for ( Iter2 = v2.begin( ) ; Iter2 != v2.end( ) ; Iter2++ )
      cout << *Iter2 << " ";
   cout << ")" << endl;

   cout << "v3 = ( " ;
   for ( Iter3 = v3.begin( ) ; Iter3 != v3.end( ) ; Iter3++ )
      cout << *Iter3 << " ";
   cout << ")" << endl;

   // Testing v1 and v2 for equality under identity
   bool b;
   b = equal( v1.begin( ), v1.end( ), v2.begin( ) );

   if ( b )
      cout << "The vectors v1 and v2 are equal under equality."
           << endl;
   else
      cout << "The vectors v1 and v2 are not equal under equality."
           << endl;

   // Testing v1 and v3 for equality under identity
   bool c;
   c = equal( v1.begin( ), v1.end( ), v3.begin( ) );

   if ( c )
      cout << "The vectors v1 and v3 are equal under equality."
           << endl;
   else
      cout << "The vectors v1 and v3 are not equal under equality."
           << endl;

   // Testing v1 and v3 for equality under twice
   bool d;
   d = equal( v1.begin( ), v1.end( ), v3.begin( ), twice );

   if ( d )
      cout << "The vectors v1 and v3 are equal under twice."
           << endl;
   else
      cout << "The vectors v1 and v3 are not equal under twice."
           << endl;

}